package com.swtb.fontexample.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.swtb.font.client.Simplex;
import com.swtoolbox.canvasfont.client.SWTBCanvasText;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class SWTBFontExample implements EntryPoint {
	
	Simplex simplex = new Simplex();
	
	public void onModuleLoad() {
		RootPanel rootPanel = RootPanel.get();

		SWTBCanvasText canvas = new SWTBCanvasText(800, 600);
		rootPanel.add(canvas);
		
		canvas.setFont(simplex);
		
		canvas.saveContext();
		canvas.beginPath();
		canvas.textTo("Hello world!", 20.0, 350.0, 0.0, 2.0);
		canvas.stroke();
		canvas.restoreContext();
		
		canvas.saveContext();
		canvas.setLineWidth(2.0);
		canvas.beginPath();
		canvas.textTo("This should be in bold", 20.0, 60.0, 0.0, 1.0);
		canvas.stroke();
		canvas.restoreContext();
		
		canvas.saveContext();
		canvas.setItalic(true);
		canvas.beginPath();
		canvas.textTo("This should be in italic", 20.0, 100.0, 0.0, 1.0);
		canvas.stroke();
		canvas.restoreContext();
		
		canvas.saveContext();
		canvas.setItalic(true);
		canvas.setLineWidth(2.0);
		canvas.beginPath();
		canvas.textTo("This should be in bold and italic", 20, 140, 0.0, 1.0);
		canvas.stroke();
		canvas.restoreContext();
		
		canvas.saveContext();
		canvas.beginPath();
		canvas.moveTo(20, 180);
		canvas.textTo("This should be normal", 20, 180, 0.0, 1.0);
		canvas.stroke();
		canvas.restoreContext();
		
		canvas.saveContext();
		canvas.setItalic(true);
		canvas.setLineWidth(1.25);
		canvas.beginPath();
		canvas.textTo("Diagonal going up", 50, 580, Math.toRadians(30), 0.75);
		canvas.stroke();
		canvas.restoreContext();
		
		canvas.saveContext();
		canvas.setItalic(true);
		canvas.setLineWidth(1.25);
		canvas.beginPath();
		canvas.textTo("Diagonal going down", 50, 220, Math.toRadians(-30), 0.75);
		canvas.stroke();
		canvas.restoreContext();
		
	}
}
